package cn.edu.nwsuaf.examcenter.pojo;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * ExerciceExamAnswer entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "exercice_exam_answer", catalog = "exam")
public class ExerciceExamAnswer implements java.io.Serializable {

	// Fields

	private ExerciceExamAnswerId id;
	private Student student;
	private ExerciceExam exerciceExam;
	private String itemAnswer;

	// Constructors

	/** default constructor */
	public ExerciceExamAnswer() {
	}

	/** minimal constructor */
	public ExerciceExamAnswer(ExerciceExamAnswerId id, Student student,
			ExerciceExam exerciceExam) {
		this.id = id;
		this.student = student;
		this.exerciceExam = exerciceExam;
	}

	/** full constructor */
	public ExerciceExamAnswer(ExerciceExamAnswerId id, Student student,
			ExerciceExam exerciceExam, String itemAnswer) {
		this.id = id;
		this.student = student;
		this.exerciceExam = exerciceExam;
		this.itemAnswer = itemAnswer;
	}

	// Property accessors
	@EmbeddedId
	@AttributeOverrides({
			@AttributeOverride(name = "studentNo", column = @Column(name = "student_no", nullable = false, length = 50)),
			@AttributeOverride(name = "examNo", column = @Column(name = "exam_no", nullable = false, length = 50)),
			@AttributeOverride(name = "itemNo", column = @Column(name = "item_no", nullable = false, length = 50)) })
	public ExerciceExamAnswerId getId() {
		return this.id;
	}

	public void setId(ExerciceExamAnswerId id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "student_no", nullable = false, insertable = false, updatable = false)
	public Student getStudent() {
		return this.student;
	}

	public void setStudent(Student student) {
		this.student = student;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({
			@JoinColumn(name = "exam_no", referencedColumnName = "exam_no", nullable = false, insertable = false, updatable = false),
			@JoinColumn(name = "item_no", referencedColumnName = "item_no", nullable = false, insertable = false, updatable = false) })
	public ExerciceExam getExerciceExam() {
		return this.exerciceExam;
	}

	public void setExerciceExam(ExerciceExam exerciceExam) {
		this.exerciceExam = exerciceExam;
	}

	@Column(name = "item_answer", length = 1024)
	public String getItemAnswer() {
		return this.itemAnswer;
	}

	public void setItemAnswer(String itemAnswer) {
		this.itemAnswer = itemAnswer;
	}

}